﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types;

namespace EMC.VISITOR.Application
{
    [SugarTable(null, "訪客記錄")]
    [BusinessVS]
    public class VisitLog : EntityBase
    {
        [SugarColumn(ColumnDescription = "訪客類型", IndexGroupNameList = new string[] { "index_vislog_type" })]
        public virtual VisitorType Type { get; set; }

        [SugarColumn(ColumnDescription = "訪客手機", Length = 50, IndexGroupNameList = new string[] { "index_vislog_vphone" })]
        public virtual string? Vphone { get; set; }

        [SugarColumn(ColumnDescription = "訪客姓名", Length = 50, IsNullable = true)]
        public virtual string Visitor { get; set; }

        [SugarColumn(ColumnDescription = "訪客性別")]
        public virtual SexType? Sex { get; set; }

        [SugarColumn(ColumnDescription = "訪客身份證", Length = 50)]
        public virtual string? IdCard { get; set; }

        [SugarColumn(ColumnDescription = "访客证件照片", Length = 300)]
        public virtual string? IdCardImg { get; set; }


        [SugarColumn(ColumnDescription = "預約來訪時間", IsNullable = true, IndexGroupNameList = new string[] { "index_vislog_visittime" })]
        public virtual DateTime? VisitTime { get; set; }

        [SugarColumn(ColumnDescription = "預約結束時間", IsNullable = true)]
        public virtual DateTime? VendTime { get; set; }

        [SugarColumn(ColumnDescription = "门卫同意时间", IsNullable = true, IndexGroupNameList = new string[] { "index_vislog_waitentertime" })]
        public virtual DateTime? WaitToEnterTime { get; set; }

        [SugarColumn(ColumnDescription = "出入門禁點", Length = 100)]
        public virtual string? VisitSite { get; set; }

        [SugarColumn(ColumnDescription = "來訪單位", Length = 100, IndexGroupNameList = new string[] { "index_vislog_vcompany" })]
        public virtual string? Vcompany { get; set; }

        [SugarColumn(ColumnDescription = "訪客人數")]
        public virtual long? Vnum { get; set; }

        [SugarColumn(ColumnDescription = "拜訪事由",ColumnDataType ="text")]
        public virtual string? Vreason { get; set; }

        [SugarColumn(ColumnDescription = "人臉頭像", Length = 300)]
        public virtual string? Vimg { get; set; }

        [SugarColumn(ColumnDescription = "自带货物描述", Length = 300)]
        public virtual string? HwImg { get; set; }

        [SugarColumn(ColumnDescription = "作業區域", Length = 100)]
        public virtual string? VisitArea { get; set; }

        [SugarColumn(ColumnDescription = "證件照片", Length = 2000)]
        public virtual string? DocImg { get; set; }

        [SugarColumn(ColumnDescription = "車牌號", Length = 50, IndexGroupNameList = new string[] { "index_vislog_carno" })]
        public virtual string? CarNo { get; set; }

        [SugarColumn(ColumnDescription = "物品信息", ColumnDataType ="text")]
        public virtual string? GoodsInfo { get; set; }

        [SugarColumn(ColumnDescription = "部門")]
        public virtual long? DeptId { get; set; }

        [SugarColumn(ColumnDescription = "審批人姓名", IndexGroupNameList = new string[] { "index_vislog_leadid" })]
        public virtual long? LeaderId { get; set; }
        [SugarColumn(ColumnDescription = "最终審批人姓名", IndexGroupNameList = new string[] { "index_vislog_lastleadname" })]
        public virtual string? LastLeaderName { get; set; }

        [SugarColumn(ColumnDescription = "被訪人姓名", Length = 400)]
        public virtual string? Staff { get; set; }

        [SugarColumn(ColumnDescription = "被訪人手機", Length = 400)]
        public virtual string? Iphone { get; set; }

        [SugarColumn(ColumnDescription = "狀態", IndexGroupNameList = new string[] { "index_vislog_status" })]
        public virtual ProcessStatus? Status { get; set; }
        [SugarColumn(ColumnDescription = "權限下發結果",Length = 1000)]
        public virtual string? AuthResultMessage { get; set; }
        [SugarColumn(ColumnDescription = "分享人Id")]
        public virtual long? IsBeShared { get; set; }

        [SugarColumn(ColumnDescription = "位置")]
        public string? Position { get; set; } = "未知";

        /// <summary>
        ///0：代表需要被访人确认 1：代表被访人已确认
        /// </summary>
        [SugarColumn(ColumnDescription = "被访人已确认", IsNullable = true)]
        public string StaffConfirm { get; set; }

        [SugarColumn(ColumnDescription = "施工人员签字图片", Length = 500)]
        public string? haImg { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(LeaderId))]
        public virtual SysUser User { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(Id))]
        public virtual VisitLogDetail Detail { get; set; }
        [Navigate(NavigateType.OneToMany, nameof(DoorInOutRecord.personId), nameof(Id))]
        public virtual List<DoorInOutRecord> DoorRecords { get; set; }
        [Navigate(NavigateType.OneToMany, nameof(HKCrossRecord.plateNo), nameof(CarNo))]
        public virtual List<HKCrossRecord> CardRecords { get; set; }
    }
}
